<?php
//=======================================
//###################################
// Kayako Web Solutions
//
// Source Copyright 2001-2004 Kayako Web Solutions
// Unauthorized reproduction is not allowed
// License Number: $%LICENSE%$
// $Author: vshoor $ ($Date: 2005/05/26 22:02:02 $)
// $RCSfile: visitor_adtracking.php,v $ : $Revision: 1.3 $ 
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
//###################################
//=======================================


if (!defined("INSWIFT")) {
	trigger_error("Unable to process $PHP_SELF", E_USER_ERROR);
}

require_once ("./includes/functions_html.php");
require_once ("./modules/livesupport/functions_adtracking.php");
$template->loadLanguageSection("livesupportclient");

/**
* ###############################################
* VISITOR AD TRACKING HIT
* ###############################################
*/
if ($eventaction == "track" && trim($_GET["campaignid"]) != "") {
	$cookie->parseCookie("visitor");

	$_campaign = $dbCore->queryFetch("SELECT * FROM `". TABLE_PREFIX ."adcampaigns` WHERE `campaignid` = '". $dbCore->escape($_GET["campaignid"]) ."';");

	if (empty($_campaign["campaignid"]))
	{
		echo $_SWIFT["language"]["campaignerror"];
		exit;
	}

	$cookie->addCookie("visitor", "campaignid", $_campaign["campaignid"]);
	$cookie->addCookie("visitor", "campaigntitle", $_campaign["title"]);
	$cookie->buildCookie("visitor");

	addHitLog($_campaign["campaignid"]);
	printRedirect($_SWIFT["language"]["adtrackingredirect"], $_campaign["redirecturl"]);
}
?>